<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .content {
      margin: 150px auto;
      width: 900px;
    }
  </style>
</head>
<body>
  <div id="app" class="content">
    {{message}}
  </div>
  <div id="app-2">
    <span v-bind:title="message">鼠标悬停几秒钟查看此处动态绑定的提示信息！</span>
  </div>
  <div id="app-3">
    <p v-if="seen">现在看到我了</p>
  </div>
  <div id="app-4">
    <ol>
      <li v-for="todo in todos">
        {{todo.text}}
      </li>
    </ol>
  </div>
  <div id="app-5">
    <p>{{ message }}</p>
    <button v-on:click="reverseMessage">逆转消息</button>
  </div>
  <div id="app-6">
    <p>{{ message }}</p>
    <input v-model="message">
    <ol>
      <todo-item></todo-item>
    </ol>
  </div>
  <div id="app-7">   
    <ol>
      <todo-item2 v-for="item in groceryList" v-bind:todo="item"></todo-item2>
    </ol>
  </div>
  <script src="../js/lib/vue.js"></script>
  <script src="../js/lib/art-template.js"></script>
  <script src="../js/lib/jquery-2.1.1.js"></script>
  <script>   
    var app = new Vue({
      el: "#app",
      data: {
        message: "Hello Vue!"
      }
    });
    var app2 = new Vue({
      el: '#app-2',
      data: {
        message: "页面加载于 " + new Date()
      }
    });
    var app3 = new Vue({
      el: '#app-3',
      data: {
        seen: true
      }
    });
    var app4 = new Vue({
      el: '#app-4',
      data: {
        todos: [
          { text: '学习 JavaScript' },
          { text: '学习 Vue' },
          { text: '整个牛项目' }
        ]
      }
    });
    var app5 = new Vue({
      el: '#app-5',
      data: {
        message: "hello vue message"
      },
      methods: {
        reverseMessage: function() {
          console.log(this);
          this.message = this.message.split('').reverse().join('')
        }
      }
    });

    // 要定义在app实例化之前，并且要使用在APP标签内
    Vue.component('todo-item', {
      template: '<li>这是个待办项</li>'
    })
    var app6 = new Vue({
      el: '#app-6',
      data: {
        message: "hello vue"
      }
    });


    Vue.component('todo-item2', {
      props: ['todo'],
      template: '<li>{{todo.text}}</li>'
    });
    var app7 = new Vue({
      el: '#app-7',
      data: {
        groceryList: [
          {text: '土豆'},
          {text: '西红柿'},
          {text: '大白菜'},
          {text: '茄子'}
        ]
      }
    });

  </script>
</body>
</html>